﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OleDb;




namespace ArcMap_AddIn_Tools.Core.NETWrapper
{
    //ADONET的更抽象封装
    public static class  ADONETWrapper
    {
        
        /// <summary>
        /// 从MDB文件中读取Table
        /// </summary>
        /// <param name="strPath">mdb路径</param>
        /// <param name="table">表名称</param>
        public static DataTable ReadTableFromMDB(string mdbPath, string tableName)
        {
            

            try
            {

                //1、建立连接 
                string sAccessConnection = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mdbPath;
                OleDbConnection odcConnection = new OleDbConnection(sAccessConnection);
                //2、打开连接 
                odcConnection.Open();
                string strSQL = "SELECT * FROM " + tableName;
                OleDbDataAdapter adp = new OleDbDataAdapter(strSQL, odcConnection);
                DataTable dt = new DataTable();
                adp.Fill(dt);
                //关闭连接
                odcConnection.Close();
                //读取成功后返回
                return dt;

            }
            catch (Exception ex)
            {
                return null;
            }
        }



        //建立Table的数据绑定
        //public static void 




        //将修改后的Table写入MDB文件中




        //数据绑定







       
    }

}
